package com.wltjack.sysmanage.modules.demo1.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wltjack.common.reponse.Res;
import com.wltjack.sysmanage.modules.demo1.dto.DeptListDto;
import com.wltjack.sysmanage.modules.demo1.dto.DeptAddDto;
import com.wltjack.sysmanage.modules.demo1.dto.DeptPageDto;
import com.wltjack.sysmanage.modules.demo1.entity.Dept;
import com.wltjack.sysmanage.modules.demo1.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * @ClassName Demo1Controller
 * @Description demo1
 * @Author kangliang
 * @Date 2021/03/01 11:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/multidb/demo1")
@Api(value = "demo1", tags = "系统管理-> demo")
public class Demo1Controller {

    @Autowired
    private DeptService deptService;

    @ApiOperation(value = "list", notes = "dept列表")
    @PostMapping("/list")
    public Res<Map<String, Object>> list(DeptListDto dto) {
        return Res.ok(deptService.list(dto));
    }

    @ApiOperation(value = "add", notes = "add")
    @PostMapping("/add")
    public Res<Boolean> add(DeptAddDto dto) {
        return Res.ok(deptService.insert(dto));
    }

    @ApiOperation(value = "queryDeptPage", notes = "查询dept分页记录")
    @PostMapping("/queryDeptPage")
    public Res<Page<Dept>> queryDeptPage(@Valid DeptPageDto dto) {
        return Res.ok(deptService.queryDeptPage(dto));
    }

}
